package chat;

import java.io.OutputStream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2024-09-12
 * Time: 18:50
 */
public class Client {
    public static void main(String[] args) throws IOException {

        // 创建一个客户端   ipconfig   IPV4
        Socket socket = new Socket("127.0.0.1",8888);

        // 客户端创建成功,并且连接到服务器了
        System.out.println("创建成功,并且连接到服务器");
        String msg = "在干嘛";
        OutputStream outputStream = socket.getOutputStream();
        outputStream.write(msg.getBytes());
        outputStream.flush();
        InputStream inputStream = socket.getInputStream();
        byte[] b = new byte[1024];
        int len;
        while ((len=inputStream.read(b))!=-1) {
            System.out.println(new String(b,0,len));
        }

//        new ForwardMsg(socket).start();
//        new ReceiveMsg(socket).start();
    }
}
